<template>
	<view class="content">
		<view class="tabsBox">
			<!-- <v-tabs v-model="menuIndex" :tabs="['免费课程','付费课程']" bgColor="transparent" activeColor="#f08229"
				lineColor="#f08229" color="#00000" lineHeight='5rpx' @change="changeMenu()" class="vtabs"
				lineScale="0.6"></v-tabs> -->
		</view>
		<scroll-view class="popularCoursesList" scroll-y="true"  @scrolltolower="getMore()">
			<view class="popularCoursesItem" v-for="(item,index) in  studyCourseLists" :key="index">
				<image :src="item.cover" class="popularCover"></image>
				<!-- <image :src="baseUrl+'tuwen.png'" class="popularType" v-if="item.type==1"></image>
				<image :src="baseUrl+'video.png'" class="popularType" v-else-if="item.type==2"></image>
				<image :src="baseUrl+'livingIcon.png'" class="popularType1" v-else-if="item.type==3"></image>
				<image :src="baseUrl+'canOrderIcon.png'" class="popularType1" v-else-if="item.type==4"></image>
				<image :src="baseUrl+'end.png'" class="popularType1" v-else-if="item.type==5"></image> -->
				<image :src="baseUrl+'tuwenIcon.png'" class="tuwenIcon" v-if="item.type=='图文'" />
				<image :src="baseUrl+'videoIcon.png'" class="videoIcon" v-if="item.type=='视频'" />
				<image :src="baseUrl+'voice.png'" class="orderIcon" v-if="item.type=='音频'" />
				<image :src="baseUrl+'live.png'" class="liveIcon" v-if="item.type=='直播'" />
				<text class="popularTitle">{{item.name}}</text>
				<block v-if="item.type=='直播'">
					<view class="liveTeacherBox">
						<image :src="baseUrl+'person.png'" class="livePersonIcon"></image>
						<text class="liveTeacherName">导师：{{$teacher(item.teacher_arr)}}</text>
					</view>
					<view class="liveTimeBox">
						<image :src="baseUrl+'time.png'" class="liveTimeIcon"></image>
						<text class="liveTime">{{item.live_time}}</text>
					</view>
				</block>
				<view class="popularNumBox" v-else>
					<image :src="baseUrl+'arrow.png'" class="arrowIcon"></image>
					<text class="peopleLabel">{{item.study_num}}人在学习</text>
					<text class="line1"></text>
					<image :src="baseUrl+'time.png'" class="timeIcon"></image>
					<text class="popularTotal">共{{item.catelogue_count}}讲</text>
				</view>
				<text class="waitLearn" @click="$navto.navto('/course/info/info',{id:item.id})">去学习</text>
				<!-- <text class="end">已结束</text> -->
				<!-- <text class="waitLive">未开播</text> -->
				<!-- <text class="popularPrice" v-if="item.fee_type==1">￥{{item.price}}</text>
				<text class="popularPrice" v-else>免费</text> -->
				<!-- <view class="learnBtn" v-if="item.type==4">了解课程</view> -->
				<!-- <view class="endBtn" v-else-if="item.type==5">已结束</view> -->
				<!-- <view class="learnBtn" v-else>立即学习</view> -->
				<view class="line" v-if="index!=studyCourseLists.length-1"></view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import {
		baseURL,
		basePath
	} from '@/config/app'
	export default {
		data() {
			return {
				menuIndex: 0,
				baseUrl: `https://cdn.zkjialan.com/img/course/`,
				studyCourseLists: [],
				page_no:1
			}
		},
		onShow() {
			//查询我的课程
			this.getLists();
		},
		methods: {
			getMore() {
				// this.page_no++;
				// this.$request.get(`course/course/studyCourseLists`).then(res => {
				// 	this.studyCourseLists.push(...res.data.data);
				// })
			},
			getLists(){
				this.$request.get(`course/course/studyCourseLists`).then(res => {
					console.log(res.data);
					this.studyCourseLists = res.data.data;
				})
			},
			changeMenu(index) {
				console.log('当前选中的项：' + index)
				this.page_no=1;
				this.getLists();
			},
		}
	}
</script>

<style lang="scss" scoped>
	.tabsBox {
		width: 60%;
		margin-left: 20%;
	}

	.line {
		width: 674rpx;
		height: 1rpx;
		background-color: #dcdcdc;
		margin-top: 70rpx;
	}

	.popularCoursesList {
		width: 674rpx;
		margin-left: 37rpx;
		margin-top: 65rpx;
		height: 90vh;
		.liveTimeBox {
			position: absolute;
			top: 81rpx;
			left: 320rpx;
			display: flex;

			.liveTimeIcon {
				width: 21rpx;
				height: 21rpx;
			}

			.liveTime {
				font-size: 19rpx;
				color: #8e8e8e;
				margin-left: 15rpx;
			}
		}

		.liveTeacherBox {
			position: absolute;
			top: 47rpx;
			left: 320rpx;
			display: flex;

			.livePersonIcon {
				width: 21rpx;
				height: 20rpx;
			}

			.liveTeacherName {
				font-size: 19rpx;
				color: #8e8e8e;
				margin-left: 15rpx;
			}
		}

		.popularCoursesItem {
			position: relative;
			width: 674rpx;
			margin-bottom: 45rpx;

			.orderIcon,
			.liveIcon {
				width: 92rpx;
				height: 40rpx;
				margin-left: 45rpx;
			}

			.tuwenIcon,
			.videoIcon {
				width: 72rpx;
				height: 38rpx;
				margin-left: 45rpx;
			}

			.endBtn {
				position: absolute;
				width: 128rpx;
				height: 50rpx;
				border-radius: 25rpx;
				background-color: #c8c8c8;
				top: 127rpx;
				right: 37rpx;
				font-size: 22rpx;
				color: #fff;
				line-height: 50rpx;
				text-align: center;
				font-family: 'ar';
			}

			.learnBtn {
				position: absolute;
				width: 128rpx;
				height: 50rpx;
				border-radius: 25rpx;
				background-color: #f08329;
				top: 127rpx;
				right: 37rpx;
				font-size: 22rpx;
				color: #fff;
				line-height: 50rpx;
				text-align: center;
				font-family: 'ar';
			}

			.waitLearn {
				// position: absolute;
				// color: #f08229;
				// top: 0rpx;
				// right: 0rpx;
				// font-size: 25rpx;
				// font-family: 'ar';
				
				position: absolute;
				width: 128rpx;
				height: 50rpx;
				border-radius: 25rpx;
				background-color: #f08329;
				top: 134rpx;
				right: 0rpx;
				font-size: 22rpx;
				color: #fff;
				line-height: 50rpx;
				text-align: center;
				font-family: 'ar';
				
				
			}

			.end {
				position: absolute;
				color: #8e8e8e;
				top: 0rpx;
				right: 0rpx;
				font-size: 25rpx;
				font-family: 'ar';
			}

			.waitLive {
				position: absolute;
				color: #141414;
				top: 0rpx;
				right: 0rpx;
				font-size: 25rpx;
				font-family: 'ar';
			}

			.popularPrice {
				position: absolute;
				color: #f08329;
				top: 140rpx;
				left: 320rpx;
				font-size: 28rpx;
				font-family: 'am';
			}

			.popularNumBox {
				position: absolute;
				width: 100%;
				height: 24rpx;
				left: 320rpx;
				top: 60rpx;
				display: flex;
				align-items: flex-start;

				.arrowIcon {
					width: 22rpx;
					height: 24rpx;
					margin-top: 5rpx;
				}

				.peopleLabel {
					font-size: 19rpx;
					color: #8e8e8e;
					margin-left: 15rpx;
					font-family: 'ar';
				}

				.line1 {
					width: 1rpx;
					height: 20rpx;
					margin-left: 30rpx;
					background-color: #dcdcdc;
					margin-top: 5rpx;
				}

				.timeIcon {
					width: 21rpx;
					height: 21rpx;
					margin-left: 30rpx;
					margin-top: 5rpx;
				}

				.popularTotal {
					font-size: 19rpx;
					color: #8e8e8e;
					margin-left: 15rpx;
					font-family: 'ar';
				}
			}

			.popularTitle {
				position: absolute;
				font-size: 27rpx;
				color: #141414;
				top: 0;
				left: 320rpx;
				font-family: 'am';
				width: 250rpx;
				overflow: hidden;
				white-space: nowrap;
				text-overflow: ellipsis;
			}

			.popularType {
				position: absolute;
				width: 68rpx;
				height: 37rpx;
				left: 0;
				top: 0;
			}

			.popularType1 {
				position: absolute;
				width: 73rpx;
				height: 37rpx;
				left: 0;
				top: 0;
			}

			.popularCover {
				width: 271rpx;
				height: 177rpx;
				border-radius: 10rpx;
			}
		}
	}

	/deep/.v-tabs__container {
		justify-content: space-between;
	}

	.vtabs {
		margin-top: 50rpx;
	}

	.content {
		position: fixed;
		width: 100%;
		height: 100%;
		overflow-y: scroll;
		overflow-x: hidden;
		background-color: #fff;
	}

	page {
		width: 100%;
		height: 100%;
		overflow-y: scroll;
		background-color: #fff !important;
		padding-bottom: 0 !important;
	}
</style>